package demo4.controller;

import com.tedu.InputUtil;
import demo4.mapper.IUserMapper;
import demo4.vo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Controller
 * 后期是负责和客户端打交道，接受客户端的请求以及数据，然后处理对应的业务
 * 并根据不同的处理结果给与客户端对应的响应
 */
@Component
public class UserController {
    @Autowired
    private IUserMapper userMapper;
    public void regUser(){
        User user = InputUtil.getInputObject(new User(),"欢迎注册");
        if(userMapper.selectByUsername(user.getUsername()) == null){
            userMapper.insert(user);
            System.out.println("恭喜您注册成功！");
        } else {
            System.out.println("该用户已存在");
        }

    }
}
